package com.esri.core.tasks.ags.geoprocessing;

import com.esri.core.internal.io.handler.h;
import com.esri.core.internal.io.handler.n;
import com.esri.core.internal.util.d;
import com.esri.core.io.EsriServiceException;
import com.esri.core.io.UserCredentials;
import com.esri.core.map.WebMapQuery;
import java.util.ArrayList;
import java.util.Map;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class GPTaskInfo {
    private String _category;
    private String _displayName;
    private ExecutionType _execType;
    private String _helpUrl;
    private String _name;
    private GPParameterInfo[] _parameterInfo;

    /* loaded from: classes.dex */
    public static class GPParameterInfo {
        private String _category;
        private String[] _choiceList;
        private Class<?> _dataType;
        private GPParameter _defaultValue;
        private ParamDirection _direction;
        private String _displayName;
        private String _name;
        private ParamType _type;

        public static GPParameterInfo fromJson(JsonParser jsonParser) throws Exception {
            if (!d.c(jsonParser)) {
                throw new EsriServiceException("Unable to parse the Response for this GPParameterInfo.");
            }
            GPParameterInfo gPParameterInfo = new GPParameterInfo();
            GPParameter gPParameter = null;
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("name".equals(currentName)) {
                    gPParameterInfo.setName(jsonParser.getText().trim());
                } else if ("dataType".equals(currentName)) {
                    gPParameterInfo.setDataType(jsonParser.getText());
                } else if ("displayName".equals(currentName)) {
                    gPParameterInfo.setDisplayName(jsonParser.getText().trim());
                } else if ("direction".equals(currentName)) {
                    gPParameterInfo.setDirection(ParamDirection.fromString(jsonParser.getText()));
                } else if (WebMapQuery.PARAM_DEFAULTVALUE.equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                        gPParameter = GPParameter.createFromJson(jsonParser);
                        gPParameterInfo.setDefaultValue(gPParameter);
                    } else {
                        jsonParser.skipChildren();
                    }
                } else if ("parameterType".equals(currentName)) {
                    gPParameterInfo.setParameterType(ParamType.fromString(jsonParser.getText()));
                } else if ("category".equals(currentName)) {
                    gPParameterInfo.setCategory(jsonParser.getText());
                } else if ("choiceList".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        ArrayList arrayList = new ArrayList();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                                arrayList.add(jsonParser.getText());
                            } else {
                                jsonParser.skipChildren();
                            }
                        }
                        gPParameterInfo.setChoiceList((String[]) arrayList.toArray(new String[0]));
                    }
                } else {
                    jsonParser.skipChildren();
                }
            }
            if (gPParameter != null) {
                gPParameter.setParamName(gPParameterInfo.getName());
            }
            return gPParameterInfo;
        }

        protected void setName(String str) {
            this._name = str;
        }

        public String getName() {
            return this._name;
        }

        protected void setDisplayName(String str) {
            this._displayName = str;
        }

        public String getDisplayName() {
            return this._displayName;
        }

        protected void setCategory(String str) {
            this._category = str;
        }

        public String getCategory() {
            return this._category;
        }

        protected void setDataType(String str) {
            if (str.contains("GPBoolean")) {
                this._dataType = GPBoolean.class;
            } else if (str.contains("GPDataFile")) {
                this._dataType = GPDataFile.class;
            } else if (str.contains("GPDate")) {
                this._dataType = GPDate.class;
            } else if (str.contains("GPDouble")) {
                this._dataType = GPDouble.class;
            } else if (str.contains("GPFeatureRecordSetLayer")) {
                this._dataType = GPFeatureRecordSetLayer.class;
            } else if (str.contains("GPLinearUnit")) {
                this._dataType = GPLinearUnit.class;
            } else if (str.contains("GPLong")) {
                this._dataType = GPLong.class;
            } else if (str.contains("GPMapImage")) {
                this._dataType = GPMapImage.class;
            } else if (str.contains("GPRasterData")) {
                this._dataType = GPRasterData.class;
            } else if (str.contains("GPRasterDataLayer")) {
                this._dataType = GPRasterDataLayer.class;
            } else if (str.contains("GPRecordSet")) {
                this._dataType = GPRecordSet.class;
            } else if (str.contains("GPString")) {
                this._dataType = GPString.class;
            }
        }

        public Class<?> getDataType() {
            return this._dataType;
        }

        protected void setDirection(ParamDirection paramDirection) {
            this._direction = paramDirection;
        }

        public ParamDirection getDirection() {
            return this._direction;
        }

        protected void setParameterType(ParamType paramType) {
            this._type = paramType;
        }

        public ParamType getParameterType() {
            return this._type;
        }

        protected void setChoiceList(String[] strArr) {
            this._choiceList = strArr;
        }

        public String[] getChoiceList() {
            return this._choiceList;
        }

        protected void setDefaultValue(GPParameter gPParameter) {
            this._defaultValue = gPParameter;
        }

        public GPParameter getDefaultValue() {
            return this._defaultValue;
        }
    }

    /* loaded from: classes.dex */
    public enum ExecutionType {
        ESRI_EXECUTION_TYPE_ASYNCHRONOUS("esriExecutionTypeAsynchronous"),
        ESRI_EXECUTION_TYPE_SYNCHRONOUS("esriExecutionTypeSynchronous");
        
        String value;

        /* JADX INFO: Access modifiers changed from: package-private */
        public static ExecutionType fromString(String str) {
            return str.equalsIgnoreCase("esriExecutionTypeAsynchronous") ? ESRI_EXECUTION_TYPE_ASYNCHRONOUS : str.equalsIgnoreCase("esriExecutionTypeSynchronous") ? ESRI_EXECUTION_TYPE_SYNCHRONOUS : null;
        }

        ExecutionType(String str) {
            this.value = str;
        }

        @Override // java.lang.Enum
        public String toString() {
            return this.value;
        }
    }

    /* loaded from: classes.dex */
    public enum ParamDirection {
        ESRI_GP_PARAMETER_DIRECTION_INPUT("esriGPParameterDirectionInput"),
        ESRI_GP_PARAMETER_DIRECTION_OUTPUT("esriGPParameterDirectionOutput");
        
        String value;

        ParamDirection(String str) {
            this.value = str;
        }

        @Override // java.lang.Enum
        public String toString() {
            return this.value;
        }

        static ParamDirection fromString(String str) {
            return str.equalsIgnoreCase("esriGPParameterDirectionOutput") ? ESRI_GP_PARAMETER_DIRECTION_OUTPUT : ESRI_GP_PARAMETER_DIRECTION_INPUT;
        }
    }

    /* loaded from: classes.dex */
    public enum ParamType {
        ESRI_GP_PARAMETER_TYPE_REQUIRED("esriGPParameterTypeRequired"),
        ESRI_GP_PARAMETER_TYPE_OPTIONAL("esriGPParameterTypeOptional"),
        ESRI_GP_PARAMETER_TYPE_DERIVED("esriGPParameterTypeDerived");
        
        String value;

        ParamType(String str) {
            this.value = str;
        }

        @Override // java.lang.Enum
        public String toString() {
            return this.value;
        }

        static ParamType fromString(String str) {
            ParamType paramType = ESRI_GP_PARAMETER_TYPE_REQUIRED;
            if (str.equalsIgnoreCase("esriGPParameterTypeOptional")) {
                paramType = ESRI_GP_PARAMETER_TYPE_OPTIONAL;
            }
            return str.equalsIgnoreCase("esriGPParameterTypeDerived") ? ESRI_GP_PARAMETER_TYPE_DERIVED : paramType;
        }
    }

    public static GPTaskInfo fromUrl(String str) throws Exception {
        return fromJson(h.a(str, (Map<String, String>) null));
    }

    public static GPTaskInfo fromUrl(String str, UserCredentials userCredentials) throws Exception {
        return fromJson(h.a(str, (Map<String, String>) null, n.a(str, userCredentials)));
    }

    public static GPTaskInfo fromJson(JsonParser jsonParser) throws Exception {
        if (!d.c(jsonParser)) {
            throw new EsriServiceException("Unable to parse the Response for this GPTaskInfo.");
        }
        GPTaskInfo gPTaskInfo = new GPTaskInfo();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("name".equals(currentName)) {
                gPTaskInfo.setName(jsonParser.getText());
            } else if ("displayName".equals(currentName)) {
                gPTaskInfo.setDisplayName(jsonParser.getText());
            } else if ("category".equals(currentName)) {
                gPTaskInfo.setCategory(jsonParser.getText());
            } else if ("helpUrl".equals(currentName)) {
                gPTaskInfo.setHelpUrl(jsonParser.getText());
            } else if ("executionType".equals(currentName)) {
                gPTaskInfo.setExecutionType(ExecutionType.fromString(jsonParser.getText()));
            } else if ("parameters".equals(currentName)) {
                if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                    ArrayList arrayList = new ArrayList();
                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                        if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                            arrayList.add(GPParameterInfo.fromJson(jsonParser));
                        } else {
                            jsonParser.skipChildren();
                        }
                    }
                    gPTaskInfo.setParameters((GPParameterInfo[]) arrayList.toArray(new GPParameterInfo[0]));
                }
            } else {
                jsonParser.skipChildren();
            }
        }
        return gPTaskInfo;
    }

    protected void setName(String str) {
        this._name = str;
    }

    public String getName() {
        return this._name;
    }

    protected void setDisplayName(String str) {
        this._displayName = str;
    }

    public String getDisplayName() {
        return this._displayName;
    }

    protected void setCategory(String str) {
        this._category = str;
    }

    public String getCategory() {
        return this._category;
    }

    protected void setHelpUrl(String str) {
        this._helpUrl = str;
    }

    public String getHelpUrl() {
        return this._helpUrl;
    }

    protected void setExecutionType(ExecutionType executionType) {
        this._execType = executionType;
    }

    public ExecutionType getExecutionType() {
        return this._execType;
    }

    protected void setParameters(GPParameterInfo[] gPParameterInfoArr) {
        this._parameterInfo = gPParameterInfoArr;
    }

    public GPParameterInfo[] getParameters() {
        return this._parameterInfo;
    }
}
